<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <title>Title</title>
  </head>
  <body>
  
  </body>
  
  <script>
    /* Object.is方法用于严格判断两个值是否相等 */
    {
      console.log(Object.is(+0, -0)) // false
      console.log(Object.is(NaN, NaN)) // true
      
      console.log(+0 === -0) // true
      console.log(NaN === NaN) // false
    }
    
    /* Object.assign方法用于合并对象（浅拷贝），参数为`(目标对象, 多个源对象)` */
    {
      const target = {a: 1, b: 1}
      
      const source1 = {b: 2, c: 2}
      const source2 = {c: 3}
      
      const assign = Object.assign(target, source1, source2);
      console.log(assign) // {a: 1, b: 2, c: 3}
    }
    
    /* Object.getOwnPropertyDescriptors方法用于获取对象自身非继承的属性 */
    {
      const obj = {
        name: 'cj',
        get age() {return 12}
      }
      
      const ownPropertyDescriptors = Object.getOwnPropertyDescriptors(obj);
      console.log(ownPropertyDescriptors)
      /*{
        "name": {
        "value": "cj",
            "writable": true,
            "enumerable": true,
            "configurable": true
        },
        "age": {
          "enumerable": true,
          "configurable": true
        }
      }*/
    }
    
    /* Object.keys方法用于获取对象自身非继承的属性名数组 */
    {
      const obj = {name: 'cj', age: 12};
      
      const keys = Object.keys(obj);
      console.log(keys) // ['name', 'age']
    }
    
    /* Object.values方法用于获取对象自身非继承的属性值数组 */
    {
      const obj = {name: 'cj', age: 12};
      
      const values = Object.values(obj);
      console.log(values) // ['cj', 12]
    }
    
    /* Object.entries方法用于获取对象自身非继承的属性的键值对 */
    {
      const obj = {name: 'cj', age: 12};
      
      const entries = Object.entries(obj);
      console.log(entries) // [['name', 'age'], ['cj', 12]]
    }
    
    /* Object.fromEntries方法用于将键值对数组转为对象 */
    {
      const fromEntries = Object.fromEntries([
        ['foo', 'bar'],
        ['baz', 42]
      ]);
      console.log(fromEntries) // {foo: 'bar', baz: 42}
    }
  </script>
</html>